package com.fh_24.service;

import com.fh_24.bean.Stu;
import com.fh_24.mapper.StuMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class StuService {
    public static void main(String[] args) throws IOException {
        InputStream is = Resources.getResourceAsStream("MyBatisConfig.xml");
        SqlSessionFactory fy = new SqlSessionFactoryBuilder().build(is);
        SqlSession sq = fy.openSession(true);
        StuMapper mp = sq.getMapper(StuMapper.class);
        List<Stu> stus = mp.selectAll();
        for (Stu stu : stus) {

        System.out.println(stu);
        }


//        InputStream is = Resources.getResourceAsStream("MyBatisConfig.xml");
//        SqlSessionFactory sq = new SqlSessionFactoryBuilder().build(is);
//        SqlSession sq1 = sq.openSession();
//        StuMapper mp = sq1.getMapper(StuMapper.class);
//        List<Cla> clas = mp.selectAllcla();
//        for (Cla cla : clas) {
//        System.out.println(cla);
//        }
        is.close();

    }

}
